package com.GPS_based_training.support;


/**
 * @author Danilo Dessi'
 * TrainingElement describes a single detection
 */

public class TrainingElement {
	
	
	private double speed;		// The speed of detection
	private double distance;	// The distance of detection from previous detection
	private double time;		// The time of detection from the start of training
	private double latitude;	// The latitude of detection
	private double longitude;	// The longitude of detection	
	
	private final double DIVISOR_FROM_HOURS_TO_MINUTE = 60;
	private final double MIN_SPEED = 1;
	
	public TrainingElement(double speed, double distance, double time, double latitude, double longitude) {
		
		this.speed = speed;
		this.distance = distance;
		this.time = time;
		this.latitude = latitude;
		this.longitude = longitude;
		
	}
	
	/**
	 * @author Danilo Dessi'
	 * Return the speed of detection
	 * @return speed
	 */
	public double getSpeed() {
		return speed;
	}
	
	/**
	 * @author Danilo Dessi'
	 * Sets the value of speed
	 * @param speed
	 */
	public void setSpeed(double speed) {
		this.speed = speed;
	}
	
	/**
	 * @author Danilo Dessi'
	 * Return the distance of detection
	 * @return distance
	 */
	public double getDistance() {
		return distance;
	}
	
	/**
	 * @author Danilo Dessi'
	 * Sets the value of distance
	 * @param distance 
	 */
	public void setDistance(double distance) {
		this.distance = distance;
	}
	
	/**
	 * @author Danilo Dessi'
	 * Return the time of detection
	 * @return time
	 */
	public double getTime() {
		return time;
	}
	
	/**
	 * @author Danilo Dessi'
	 * Sets the value of time
	 * @param time
	 */
	public void setTime(double time) {
		this.time = time;
	}
	
	/**
	 * @author Danilo Dessi'
	 * Return the latitude of detection
	 * @return latitude
	 */
	public double getLatitude() {
		return latitude;
	}

	/**
	 * @author Danilo Dessi'
	 * Sets the value of latitude
	 * @param latitude
	 */
	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}

	/**
	 * @author Danilo Dessi'
	 * Return the longitude of detection
	 * @return longitude
	 */
	public double getLongitude() {
		return longitude;
	}

	/**
	 * @author Danilo Dessi'
	 * Sets the value of longitude
	 * @param longitude
	 */
	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}
	
	/**
	 * @author Danilo Dessi'
	 * This method computes the pace of the detections
	 * @return The pace of detections
	 */
	public double getPace(){
		
		double pace = 0;
		
		if(speed < MIN_SPEED) {
			pace = (1 / (MIN_SPEED / DIVISOR_FROM_HOURS_TO_MINUTE));
		} else {
			pace = (1 / (speed / DIVISOR_FROM_HOURS_TO_MINUTE));
		}
		
		return pace;
	}
	

}
